package com.jaws.demo.schedule.elasticjob;

import lombok.extern.slf4j.Slf4j;

import org.springframework.stereotype.Component;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.jaws.core.common.elasticjob.JawsSimpleJob;
import com.jaws.core.common.log.Log;

@JawsSimpleJob(cron="0 1 20 * * ? ",jobName="test123",shardingTotalCount=3,jobParameter="x=1",shardingItemParameters="0=A,1=B,2=C",
dataSource="batchDataSource",description="这是一个测试的job",overwrite=true,monitorExecution=true,monitorPort=5444)
@Component
@Slf4j
public class SimpleJob implements com.dangdang.ddframe.job.api.simple.SimpleJob {

    @Override
    public void execute(ShardingContext content) {
    	final String op = "SimpleJob.execute";
    	log.info(Log.op(op).msg("TaskId:" + content.getTaskId() + "ShardingItem:"+content.getShardingItem() + "--------------------------------------- begin").toString());
//    	log.info(Log.op(op).msg("JobName:"+content.getJobName()).toString());
//    	log.info(Log.op(op).msg("JobParameter:"+content.getJobParameter()).toString());
//    	log.info(Log.op(op).msg("ShardingItem:"+content.getShardingItem()).toString());
//    	log.info(Log.op(op).msg("ShardingParameter:"+content.getShardingParameter()).toString());
//    	log.info(Log.op(op).msg("ShardingTotalCount:"+content.getShardingTotalCount()).toString());
//        throw new RuntimeException("test123");
        try {
			Thread.currentThread().sleep(70000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	log.info(Log.op(op).msg("TaskId:" + content.getTaskId() + "ShardingItem:"+content.getShardingItem() + "--------------------------------------- end").toString());

    }
}
